﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MapObjectClassLibrary;

namespace MapObjectDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            checkBox1.Checked = true;
        }

        private void button_ZoomIn_Click(object sender, EventArgs e)
        {
            mapControl1.ZoomIn();
        }

        private void button_ZoomOut_Click(object sender, EventArgs e)
        {
            mapControl1.ZoomOut();
        }

        private void button_Pan_Click(object sender, EventArgs e)
        {
            mapControl1.Pan();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mapControl1.TrackPolygon();
        }

        private void mapControl1_TrakingFinished_1(object sender, MapObjectClassLibrary.Polygon p)
        {
            mapControl1.AddPolygon(p);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            mapControl1.Focus();
            mapControl1.SelfMouseWheel = !mapControl1.SelfMouseWheel;
        }

        private void mapControl1_MouseMove(object sender, MouseEventArgs e)
        {
            PointD pd = new PointD(e.Location.X, e.Location.Y);
            pd=mapControl1.ToMapPoint(pd);
            tss1.Text = string.Format("{0:.000000}", pd.X) + "," + string.Format("{0:.000000}", pd.Y);
            tss2.Text = "1/" + string.Format("{0:.000000}", mapControl1.DisplayScale);
        }

        private void button_option_Click(object sender, EventArgs e)
        {
            Option ow = new Option();
            if (ow.ShowDialog(this) == DialogResult.OK)
            {
                MessageBox.Show("设置成功!");
            }
            ow.Dispose();
        }


    }
}
